package main

import(
	"fmt"
)

func main(){
	fmt.Println("Hello World")
}

/**
 * Definition for singly-linked list.
 */
 type ListNode struct {
     Val int
     Next *ListNode
 }

func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
	pre := &ListNode{}
	head := pre
	sum := 0
	for l1 != nil || l2 != nil {
		sum /= 10
		if l1 != nil {
			sum += l1.Val
			l1 = l1.Next
		}
		
		if l2 != nil {
			sum += l2.Val
			l2 = l2.Next
		}
		
		node := &ListNode{Val: sum % 10, Next:nil}
		pre.Next = node
		pre = node
	}
	if sum / 10 == 1 {
	   pre.Next = &ListNode{Val:1}
	}
    return head.Next
}